package demo7;

/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/2/28 17:47
 */
public class StringBuilderDemo {
    public static void main(String[] args) {
        StringBuilder builder1 = new StringBuilder();
        StringBuilder builder2 = new StringBuilder("abc");
        String str = "abc";
        StringBuilder builder3 = new StringBuilder(str);
        String str2 = builder3.toString();

        String str3 = "好好学习java";
        //StringBuilder builder = new StringBuilder(str);
        StringBuffer builder = new StringBuffer(str);
        builder.append(",为了找个好工作");
        System.out.println(builder);
        builder.replace(9,16,"就是为了改变世界");
        System.out.println(builder);

        builder.delete(0,8);
        System.out.println(builder);
        builder.insert(0,"活着");
        System.out.println(builder);
///////////////////////第二遍
        StringBuilder buildera = new StringBuilder();
        StringBuilder builderb = new StringBuilder("abc");
        String stra = "abc";
        StringBuilder builderc = new StringBuilder(stra);
        String strb = builderc.toString();

        String strc = "好好学习java";
        //StringBuilder builder = new StringBuilder(str);
        StringBuffer buildery = new StringBuffer(stra);
        buildery.append(",为了找个好工作");
        System.out.println(buildery);
        buildery.replace(9,16,"就是为了改变世界");
        System.out.println(buildery);

        buildera.delete(0,8);
        System.out.println(buildery);
        buildery.insert(0,"活着");
        System.out.println(buildery);
    }
}
